#include <windows.h>
#include <stdio.h>
#include <fcntl.h>

#include "system.h"
#include "window.h"

void fatal(const char* err)
{
	MessageBox(0, err, "MonMan", MB_ICONSTOP);
	exit(EXIT_FAILURE);
}

void popup(const char* fmt, ...)
{
	char buf[256];
	va_list va;
	va_start(va, fmt);
	
	vsprintf(buf, fmt, va);
	
	MessageBox(0, buf, "MonMan", MB_ICONINFORMATION);
	
	va_end(va);
}

void init_debug(void)
{
	int crtout;
	FILE *fd;
	
	AllocConsole();
	crtout = _open_osfhandle(
		(long) GetStdHandle(STD_OUTPUT_HANDLE),
		_O_TEXT );
	
	fd = _fdopen(crtout, "w");
	
	*stdout = *fd;
}
